package com.example.demo.service;/**
 * ClassName: RepairService
 * Package: com.example.demo.service
 * Description:
 *
 * @Author 理理
 * @Create 2024/11/16 19:37
 * @Version 1.0
 */

import com.example.demo.entity.Repair;
import com.example.demo.entity.Subscribe;
import com.example.demo.mapper.RepairMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 *@title: RepairService
 *@Author: Tangerine
 *@Date: 2024/11/16 19:37
 *@version 1.0
 */
@Service
public class RepairService {
    @Autowired
    private RepairMapper repairMapper;

    //分页查询数据
    public List<Repair> selectPage(Integer pageNum, Integer pageSize){
        return repairMapper.selectPage(pageNum,pageSize);
    }
    //更新数据时做判断
    public int save(Repair repair){
        //如果没有id则表明是新增
        if(repair.getId()==null){
            return repairMapper.insert(repair);
        }
        //否则就是更新
        else {
            return repairMapper.update(repair);
        }
    }

    //删除数据
    public Integer deleteById(Integer id) {
        return repairMapper.deleteById(id);
    }

    //历史预约全部
    public List<Repair> findHistory(String studentNumber){
        return repairMapper.findHistory(studentNumber);
    }
    //历史预约，分页显示
    public List<Repair> findHistoryPage(String studentNumber,Integer pageNum,Integer pageSize){
        return repairMapper.findHistoryPage(studentNumber,pageNum,pageSize);
    }

}
